{extend name="index_layout"/}
{block name="main"}
<form class="layui-form" style="margin-top: 50px" method="post">

    <input type="hidden" name="id" value="{$data.id}">

    <div class="layui-form-item">
        <label class="layui-form-label">商品分类</label>
        <div class="layui-input-block">
            <select name="cate_id" lay-verify="required" id="ccc62" lay-filter="ccc62">
                <option>请选择商品分类</option>
                {volist name="goods_cate" id="vo"}
                <option value="{$vo.id}"
                <?php if( $vo['id'] == $data['cate_id']){ ?> selected <?php }?>>{$vo.name}</option>
                {/volist}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">商品名称</label>
        <div class="layui-input-block">
            <select name="goods_id" lay-verify="required" id="goods" lay-filter="goods">
                <option>请选择商品</option>
                {volist name="goods" id="vo"}
                <option value="{$vo.id}"
                <?php if( $vo['id'] == $data['goods_id']){ ?> selected <?php }?>>{$vo.name}</option>
                {/volist}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">推广奖励</label>
        <div class="layui-input-block">
            <input type="text" name="gk_money" value="{$data.gk_money}" lay-verify="required|number" autocomplete="off" placeholder="推广奖励"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">直推奖励</label>
        <div class="layui-input-block">
            <input type="text" name="zhi_money" value="{$data.zhi_money}" lay-verify="required|number" autocomplete="off" placeholder="推广奖励"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">间推奖励</label>
        <div class="layui-input-block">
            <input type="text" name="jin_money" value="{$data.jin_money}" lay-verify="required|number" autocomplete="off" placeholder="推广奖励"
                   class="layui-input">
        </div>
    </div>

<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">成为代理购买数量</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input type="text" name="buy_num" value="{$data.buy_num}" lay-verify="required|number" autocomplete="off" placeholder="成为代理购买数量"-->
<!--                   class="layui-input">-->
<!--        </div>-->
<!--    </div>-->

    <div class="layui-form-item layer-footer">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
{/block}
{block name="script"}
<script type="text/javascript">
    layui.use(['yznForm', 'laydate','form'], function () {
        var yznForm = layui.yznForm;
        laydate = layui.laydate;
        var form = layui.form;
        yznForm.bindevent($("form.layui-form"));

        form.on('select(ccc62)', function (data) {
        console.log(data);
            $.ajax({
                type: "POST",//规定传输方式
                url: "{:url('get_goods')}",//提交URL
                data: {'id': data.value},//提交的数据
                success: function (result) {
                    if (result.code == 200) {
                        $("#goods").empty();
                        var str = "<option value>请选择商品</option>";
                        $.each(result.data, function (i, val) {
                            str += '<option value=' + val.id + '>' + val.name + '</option>'
                        });
                        $("#goods").append(str);
                        layui.form.render('select');
                    }
                },
                error: function () {
                    alert("获取信息失败")
                }
            });
            form.render();
        });
    });
</script>
{/block}